﻿using SuperX.Common;
using SuperX.Common.Abstract;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using System;

namespace SuperX.DataService.Abstract
{
    public interface IIOTag : ITag
    {
        bool Active { get; set; }
        DeviceAddress Address { get; set; }
        IGroup ParentGroup { get; }

        void Update(object newvalue, DateTime timeStamp, QUALITIES quality);

        double Interval { get; set; }

        bool Archive { get; set; }

        ReadWriteMode ReadWriteMode { get; set; }

        string Script { get; set; }

        long Maximum { get; set; }

        long Minimum { get; set; }

        string Regester { get; set; }

        string No { get; set; }

        [JsonIgnore]
        QUALITIES WriteQuality { get; set; }

        [JsonIgnore]
        object WriteValue { get; set; }

        /// <summary>
        /// 采样值，工程转换前真实值
        /// </summary>
        [JsonIgnore]
        object RawValue { get; set; }

        event EventHandler<TagChangedEventArgs> TimeTriggered;

        float ScaleValue { get; set; }

        TagConvertType ConverterType { get; set; }

        /// <summary>
        /// 单位
        /// </summary>
        string Unit { get; set; }

        void UpdateIoTagValue(object engineerValue, QUALITIES quality, DateTime timeStamp);

        void UpdateTagValue(object value, QUALITIES quality, DateTime timeStamp, string updateSourceName);

        void WriteTagValue(object value, QUALITIES quality, DateTime timeStamp);

        void UpdateQAndS(DateTime timeStamp, QUALITIES quality);

        void UpdateTagValue(object rawValue);

        void ExecuteExpression();
    }
}